package cn.edu.nsmc.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import cn.edu.nsmc.common.utils.PageUtils;
import cn.edu.nsmc.common.utils.R;
import cn.edu.nsmc.modules.sys.entity.SysWorksheetRepairEvaluateEntity;
import cn.edu.nsmc.modules.sys.service.SysWorksheetRepairEvaluateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 维修类工单评分
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2024-05-08 17:01:50
 */
@RestController
@RequestMapping("sys/repair/evaluate")
public class SysWorksheetRepairEvaluateController {
    @Autowired
    private SysWorksheetRepairEvaluateService sysWorksheetRepairEvaluateService;


    @RequestMapping("/get/{id}")
    public R get(@PathVariable("id") Long id){
        return R.ok().put("data",sysWorksheetRepairEvaluateService.getById(id));
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:sysworksheetrepairevaluate:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysWorksheetRepairEvaluateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{worksheetRecordId}")
    @RequiresPermissions("generator:sysworksheetrepairevaluate:info")
    public R info(@PathVariable("worksheetRecordId") Long worksheetRecordId){
		SysWorksheetRepairEvaluateEntity sysWorksheetRepairEvaluate = sysWorksheetRepairEvaluateService.getById(worksheetRecordId);

        return R.ok().put("sysWorksheetRepairEvaluate", sysWorksheetRepairEvaluate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:sysworksheetrepairevaluate:save")
    public R save(@RequestBody SysWorksheetRepairEvaluateEntity sysWorksheetRepairEvaluate){
		sysWorksheetRepairEvaluateService.save(sysWorksheetRepairEvaluate);

        return R.ok();
    }

    @PutMapping("/wx/save")
    public R wxSave(@RequestBody SysWorksheetRepairEvaluateEntity sysWorksheetRepairEvaluate){
        if(sysWorksheetRepairEvaluate.getWorksheetRecordId() == null)return R.error();
        sysWorksheetRepairEvaluate.setCreateTime(new Date());
        sysWorksheetRepairEvaluateService.save(sysWorksheetRepairEvaluate);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:sysworksheetrepairevaluate:update")
    public R update(@RequestBody SysWorksheetRepairEvaluateEntity sysWorksheetRepairEvaluate){
		sysWorksheetRepairEvaluateService.updateById(sysWorksheetRepairEvaluate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:sysworksheetrepairevaluate:delete")
    public R delete(@RequestBody Long[] worksheetRecordIds){
		sysWorksheetRepairEvaluateService.removeByIds(Arrays.asList(worksheetRecordIds));

        return R.ok();
    }

}
